from sqlalchemy import ForeignKey

from app import db


class Evaluation(db.Model):
    __table_args__ = {
        'mysql_engine': 'InnoDB',
        'mysql_charset': 'utf8'
    }
    restaurant_id = db.Column(db.String(50), ForeignKey('restaurant.restaurant_id'))
    order_id = db.Column(db.String(50), primary_key=True)
    food_id = db.Column(db.String(50), ForeignKey('food.food_id'))
    username = db.Column(db.String(100))
    package_rating = db.Column(db.DECIMAL(5, 1))
    quality_rating = db.Column(db.DECIMAL(5, 1))
    rated_at = db.Column(db.String(255))
    rating = db.Column(db.DECIMAL(5, 1))
    rating_text = db.Column(db.String(255))
    evaluation_food = db.relationship('Evaluation', backref='food')
    evaluation_restaurant = db.relationship('Evaluation', backref='restaurant')
